package com.shujia.util

import java.io.StringReader

import org.wltea.analyzer.core.Lexeme
import org.wltea.analyzer.core.IKSegmenter

import scala.collection.mutable.ListBuffer

object IkUtil {

  def main(args: Array[String]): Unit = {

    val text: String = "数加学院牛逼，的"

    println(fit(text))
  }


  def fit(str: String): List[String] = {

    val list: ListBuffer[String] = new ListBuffer[String]

    val sr: StringReader = new StringReader(str)
    val ik: IKSegmenter = new IKSegmenter(sr, true)

    var next: Lexeme = ik.next()

    while (next != null) {
      val word: String = next.getLexemeText

      list += word

      next = ik.next()
    }

    list.toList
  }

}
